package com.xiaoxi.userserver.service.menu.impl;

import com.xiaoxi.common.exception.BMSException;
import com.xiaoxi.domain.menu.BMSMenu;
import com.xiaoxi.userserver.domain.vo.menu.BMSMoveMenu;
import com.xiaoxi.userserver.mapper.menu.BMSMenuMapper;
import com.xiaoxi.userserver.service.menu.BMSMoveMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName BMSMoveInnerMenuServiceImpl
 * @Description 在某个结点里面，说明该结点无子节点
 * @Author xiaoxi
 * @Date 2022/10/6 10:34
 * @Version 1.0
 */
@Service("BMSMenu_inner")
@Slf4j
public class BMSMoveInnerMenuServiceImpl implements BMSMoveMenuService {

    @Resource
    private BMSMenuMapper bmsMenuMapper;

    @Override
    public void move(BMSMoveMenu bmsMoveMenu) throws BMSException {

        log.info("结点：{} 在：{} 结点里面", bmsMoveMenu.getCurrentId(), bmsMoveMenu.getDropId());

        BMSMenu bmsMenu = bmsMenuMapper.selectById(bmsMoveMenu.getCurrentId());

        bmsMenu.setParentId(bmsMoveMenu.getDropId());

        bmsMenuMapper.updateById(bmsMenu);

    }

}
